import operate from '@dfeidao/atom-nodejs/db/operate';
import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import { systemid } from '../atom/config';

interface Message {
	params: {};
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string;
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:app-check-status/s002,action_id:' + action_id);
	const { exec, insert } = operate(action_id, session_id, systemid);
	// 插入数据
	insert('sign_off', message.params);
	const res = await exec();
	log('Service end path:app-check-status/s002,action_id:' + action_id);
	return {
		data: res
	};
}
